{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## After running on convert.py\n",
    "\n",
    "Please `readme.md` on `conversion` directory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from models.effnet import EfficientNet\n",
    "\n",
    "b0 = EfficientNet(1, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Load Done\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "\n",
    "state = torch.load(\"conversion/b0.pth\")\n",
    "b0.load_state_dict(state)\n",
    "b0.cuda()\n",
    "print(\"Load Done\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from loader import get_loaders\n",
    "\n",
    "_, loader = get_loaders(\"/data2/imagenet\", 1024, 224)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Acc :  0.721\n"
     ]
    }
   ],
   "source": [
    "correct = 0\n",
    "\n",
    "b0.eval()\n",
    "with torch.no_grad():\n",
    "    for input_, target_ in loader:\n",
    "        target_ = target_.cuda(non_blocking=True)\n",
    "        out = b0(input_.cuda())\n",
    "        _, idx = out.max(dim=1)\n",
    "        correct += (target_ == idx).sum().cpu().item()\n",
    "\n",
    "print(\"Acc : \", correct / len(loader.dataset))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
